package cn.fxzhang.leetcode.contest.weekd50;

/**
 * 1828. 统计一个圆中点的数目
 *
 * 类型：枚举
 * 题解：略
 * 时间复杂度：O(N*M)，圆的数量*点的数量
 * 空间复杂度：O(1)
 *
 * 提交记录(1/1)：
 * 执行用时: 20 ms
 * 内存消耗: 39.2 MB
 *
 * 【中等】通过次数2,682提交次数3,043
 * @author 张晓帆
 * @date 2021/4/17
 */
public class P5718_Queries_On_Number_Of_Points_Inside_A_Circle {

    public int[] countPoints(int[][] points, int[][] queries) {
        int n = queries.length;
        int[] ans = new int[n];
        for (int i=0; i<n; i++){
            int x = queries[i][0];
            int y = queries[i][1];
            int r = queries[i][2];
            int count = 0;
            for (int j=0; j<points.length; j++){
                if ((x-points[j][0])*(x-points[j][0])+(y-points[j][1])*(y-points[j][1])<=r*r){
                    count++;
                }
            }
            ans[i] = count;
        }
        return ans;
    }
}
